package com.rising.leetcode.editor.cn.doc.object;

import com.rising.leetcode.editor.cn.P21_MergeTwoSortedLists;

/**
 * @author LiChenYang
 * @description
 * @date 2022-06-27 16:26
 */
public class ListNode {
    public int val;
    public ListNode next;
    public ListNode(int x) {
        val = x;
        next = null;
    }
    public ListNode() {}
    public ListNode(int val, ListNode next) {
        this.val = val; this.next = next;
    }

    public static ListNode buildListNode(int[] array) {
        ListNode head = new ListNode(array[0]);
        ListNode cur = head;
        for (int i = 1; i < array.length; i++) {
            ListNode node = new ListNode(array[i]);
            cur.next = node;
            cur = cur.next;
        }
        return head;
    }
}
